package org.springcloud.wisdom.springcloud_03_freshman.admin.controller;

import org.springcloud.wisdom.springcloud_03_freshman.admin.service.AdminCardService;
import org.springcloud.wisdom.springcloud_03_freshman.common.bean.ResponseData;
import org.springcloud.wisdom.springcloud_03_freshman.common.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/card")
public class AdminCardController extends BaseController {
    @Autowired
    AdminCardService adminCardService;

    /**
     * 以分页的形式查看打卡记录
     * @param pageNum 页码数
     * @param pageSize 每页记录数
     * @return
     */
    @RequestMapping("all")
    public ResponseData<Object> getCardPage(
            @RequestParam("pageNum") int pageNum,
            @RequestParam("pageSize")int pageSize
    ){
        return returnObject(adminCardService.getPaidPage(pageNum, pageSize));
    }

    /**
     * 根据学号删除学生的打卡记录
     * @param sid
     * @return
     */
    @DeleteMapping("/del/{sid}")
    public ResponseData<Boolean> delete(@PathVariable("sid") String sid){
        return returnBoolean(adminCardService.deleteCardBySid(sid));
    }

}
